package com.aixin.csopuser.domain;


import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Date;

@Data
@ToString
public class SupplierCustomerDomain {

    private String id; // customerequity表主键，更新用
    private String UUID;
    private String customerID;//用户ID
    private String supplierID;//供应商ID
    private String custName;//用户名
    private String custServiceNum;//客户服务号
    private Integer gender;//性别
    private String certID;//证件号
    private String phoneNumber;//手机号
    private String policyNumber;//保单号
    private int custStatus;//客户状态
    private int usedNumber;//使用次数
    private String lastUseTime;//使用时间
    private String dueTime;//到期时间
    private String equityLevelID;//权益等级ID
    private String equityID;//权益ID

    public SupplierCustomerDomain(String id,
                                  String customerID,
                                  String policyNumber,
                                  String custName,
                                  String certID,
                                  String phoneNumber,
                                  Instant lastUseTime,
                                  Instant dueTime,
                                  String custLevelID,
                                  String equityID,
                                  Integer gender,
                                  Integer usedNumber) {
        this.id = id;
        this.customerID = customerID;
        this.policyNumber = policyNumber;
        this.custName = custName;
        this.certID = certID;
        this.phoneNumber = phoneNumber;
        this.equityLevelID = custLevelID;
        this.equityID = equityID;
        this.gender = (gender == null ? 0 : gender);
        this.usedNumber = (usedNumber == null ? 0 : usedNumber);

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (lastUseTime != null) {
            this.lastUseTime = formatter.format(Date.from(lastUseTime));
        }

        if (dueTime != null) {
            this.dueTime = formatter.format(Date.from(dueTime));
        }
    }
}
